//
//  ZYCAttendanceSingleDetailsCell.m
//  ZDSC
//
//  Created by 张威 on 2021/10/26.
//

#import "ZYCAttendanceSingleDetailsCell.h"
@interface ZYCAttendanceSingleDetailsCell ()
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UIView *line;

@end
@implementation ZYCAttendanceSingleDetailsCell


- (void)setIsShowDetail:(BOOL)isShowDetail{
    _isShowDetail = isShowDetail;
    if (isShowDetail) {
        _contentLabel.hidden = NO;
    }else{
        _contentLabel.hidden = YES;
    }
}
//// 1 正常 2 迟到 3 早退 4 缺卡 5 请假  6  加班
- (void)setStatus:(NSString *)status{
    _status = status;

}
- (void)setModel:(ZYCAttendanceStatusModel *)model{
    _model = model;
    _line.hidden = !model.isShow;
    if ([self.status integerValue] == 2) {// 迟到
        _titleLabel.text = [NSString stringWithFormat:@"%@ (%@) %@ ",model.attendanceDate,model.attendanceWeek,model.goToWorkTime];
        _contentLabel.text = [NSString stringWithFormat:@"迟到%@",model.lateLeave];
    }else if ([self.status integerValue] == 3) {// 早退
        _titleLabel.text = [NSString stringWithFormat:@"%@ (%@) %@",model.attendanceDate,model.attendanceWeek,model.goOffWorkTime];
        _contentLabel.text = [NSString stringWithFormat:@"下班早退%@",model.earlyLeave];
    }if ([self.status integerValue] == 4) {// 缺卡
        NSString *state = nil;
        NSString *time = nil;
        if ([model.attendanceStatus integerValue] == 4 && [model.endAttendanceStatus integerValue] == 0) {
           state = @"上班缺卡";
            time  = @"08:00";
            _titleLabel.text = [NSString stringWithFormat:@"%@ (%@) %@ ",model.attendanceDate,model.attendanceWeek,time];
            _contentLabel.text = state;
        }
        if ([model.endAttendanceStatus integerValue] == 4 && [model.attendanceStatus integerValue] == 0) {
           state = @"下班缺卡";
           time = @"17:00";
            _titleLabel.text = [NSString stringWithFormat:@"%@ (%@) %@ ",model.attendanceDate,model.attendanceWeek,time];
            _contentLabel.text = state;
        }

    }if ([self.status integerValue] == 5) {// 请假
        _titleLabel.text = [NSString stringWithFormat:@"%@ (%@) ",model.attendanceDate,model.attendanceWeek];
        _contentLabel.text = [NSString stringWithFormat:@"请假时间:%@--%@",model.leaveTime,model.leaveEndTime];
    }if ([self.status integerValue] == 6) {// 加班
        _titleLabel.text = [NSString stringWithFormat:@"%@ (%@) %@-%@ ",model.attendanceDate,model.attendanceWeek,model.goToWorkTime,model.goOffWorkTime];
        _contentLabel.text = [NSString stringWithFormat:@"加班时长:%@小时",model.workOvertimeLeave];
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.bgView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.contentLabel];
        [self.contentView addSubview:self.line];

        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.top.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(12.5f, 12.5f));
        }];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(36.0f);
            make.top.equalTo(self.bgView);
        }];

        [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bgView.mas_bottom);
            make.centerX.equalTo(self.bgView);
            make.width.mas_equalTo(2.0f);
            make.bottom.equalTo(self.contentView);
        }];
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel);
            make.top.equalTo(self.titleLabel.mas_bottom).offset(8.5f);
        }];
        

        
    }
    return self;
}


- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = HEX_RGB(@"#CECECE");
        _bgView.layer.cornerRadius = 12.5f / 2;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}


- (UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = HEX_RGB(@"#CECECE");
    }
    return _line;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 17.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 16.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _contentLabel;
}




@end
